<template>
	<view class="page">
		<view class="img-wrap"  v-if="shenhe=='0'">
			<img class="img" :src="info.image" alt="">
		</view>
		<view class="result s-flex-c-c-c">
			<img class="img" src="/static/img/dd.png" alt="">
			<view class="tit" v-if="shenhe=='0'">{{info.nickname}}</view>
			<view class="toast">预约提交成功，请等待回电！</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				userInfo: {
					name: '',
					tel: '',
					intro: '',
					admin_id: ''
				},
				info: [],
				share_code: '',
				share_title: '',
				shenhe: 0
			}
		},
		onShareAppMessage(option) {
			// option.from === 'button'
			return {
				title: this.share_title,
				desc: '在线咨询  解读报告',
				path: '/pages/index/index?id=' + this.userInfo.admin_id, // ?后面的参数会在转发页面打开时传入onLoad方法
				imageUrl: '/static/upload/share_img.jpg', // 支持本地或远程图片，默认是小程序 icon
				templateId: this.share_code,
				success() {
					console.log('转发发布器已调起，并不意味着用户转发成功，微头条不提供这个时机的回调');
				},
				fail() {
					console.log('转发发布器调起失败');
				}
			}
		},
		onLoad(option) {
			console.log(option)
			let that = this;
			uni.request({
				url: 'https://ms.ys-n.com/api/index/index',
				method: 'POST',
				header: {
					'Content-Type': 'application/json',
				},
				data: {
					'id': option.id
				},
				success: res => {
					console.log(res)
					that.info = res.data.data;
					that.userInfo.admin_id = res.data.data.id;
					that.share_code = res.data.data.share_code;
					that.share_title = res.data.data.share_title;
				},
				fail: () => {},
				complete: () => {}
			});
			
			uni.request({
				url: 'https://ms.ys-n.com/api/index/getsitea',
				method: 'POST',
				header:{
					'Content-Type' : 'application/json',
				},
				data: {},
				success: res => {
					console.log(res)
					that.shenhe= res.data.data.shenhe;
				},
				fail: () => {},
				complete: () => {}
			});

		},
		onShow(option) {

		},
		onUnload() {

		},
		computed: {
			//当前数据长度
			nowValueLength() {
				let num = this.userInfo.intro.length;
				return num;
			},
		},
		methods: {
			inputValue1(e) {
				this.userInfo.name = e.detail.value;
			},
			inputValue2(e) {
				this.userInfo.tel = e.detail.value;
			},
			inputValue3(e) {
				this.userInfo.intro = e.detail.value;
			},

			tapSubmit(e) {
				console.log(this.userInfo)
				uni.request({
					url: 'https://ms.ys-n.com/api/index/submit',
					method: 'POST',
					header: {
						'Content-Type': 'application/json',
					},
					data: this.userInfo,
					success: res => {
						if (res.data.code == 0) {
							this.$u.toast(res.data.msg);
							return;
						} else {
							this.$u.toast(res.data.msg);
							this.userInfo = {
								name: '',
								tel: '',
								intro: ''
							};
							return;
						}
						console.log(res);
					},
					fail: () => {},
					complete: () => {}
				});

			}
		}
	}
</script>

<style lang="scss" scoped>
	.result{
		width: 707rpx;
		height: 340rpx;
		background: #FFFFFF;
		box-shadow: 0rpx 1rpx 6rpx 0rpx rgba(0, 0, 0, 0.13);
		border-radius: 12rpx;
		margin: 25rpx auto;
		.img{
			width: 88rpx;
			height: 88rpx;
			margin-bottom: 44rpx;
		}
		.tit{
			font-size: 39rpx;
			font-family: _;
			font-weight: bold;
			color: #050505;
			line-height: 72rpx;
		}
		.toast{
			font-size: 29rpx;
			font-family: _;
			font-weight: 400;
			color: #000000;
			line-height: 42rpx;
		}
	}
	.img-wrap{
		width: 750rpx;
		height: 376rpx;
		.img{
			width: 100%;
			height: 100%;
		}
	}
	.m-input {
		background: #FFFFFF;
		padding: 20rpx 40rpx;
		border-bottom: 1px solid #EBEEF5;

		.label {
			font-size: 26rpx;
			color: #303133;

			.required-icon {
				color: #F56C6C;
			}
		}

		.data {
			display: flex;
			flex-direction: column;
			align-items: flex-end;

			.data-input {
				width: 100%;
				font-size: 28rpx;
				padding: 10rpx 0;
			}

			.tip {
				width: 100%;
				font-size: 24rpx;
				color: #F56C6C;
			}
		}
	}



	.m-textarea {
		background: #FFFFFF;
		padding: 20rpx 40rpx;
		border-bottom: 1px solid #EBEEF5;

		.label {
			font-size: 26rpx;
			color: #303133;

			.required-icon {
				color: #F56C6C;
			}
		}

		.data {
			display: flex;
			flex-direction: column;
			align-items: flex-end;

			.data-textarea {
				width: 100%;
				font-size: 28rpx;
				padding: 10rpx 0;
				min-height: 150rpx;

			}

			.data-text {
				font-size: 26rpx;
				color: #303133;
			}

			.tip {
				width: 100%;
				font-size: 24rpx;
				color: #F56C6C;
			}
		}
	}



	.user {
		padding: 16rpx;
		background-color: #fff;
		border-bottom: 1px solid #EBEEF5;
		display: flex;

		image {
			height: 100rpx;
			width: 100rpx;
			border-radius: 50rpx;
		}
		.r{
			padding-left: 16rpx;
			text {
				font-size: 32rpx;
				font-weight: bold;
				padding-top: 24rpx;
			}
			.info{
				font-size: 25rpx;
				color: #B50000;
				line-height: 35px;
			}
			
		}
	}
</style>
